<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue测试</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <h3>学生列表</h3>
    <ul>
      <li v-for="(item,index) in students" :key="index">
        <h4>名字:{{item.name}}----{{index}}</h4>
        <p>年龄:{{item.age}}------学校:{{item.school}}</p>
      </li>
    </ul>
    <h3>偶数年龄</h3>
    <ul>
      <li v-for="(item,index) in oddstudents" :key="index">
        <h4>名字:{{item.name}}----{{index}}</h4>
        <p>年龄:{{item.age}}------学校:{{item.school}}</p>
      </li>
    </ul>
  </div>
  <script type="text/javascript">
    var app = new Vue({
      el: '#app',
      data: {
        students: [
          { name: '小明', age: 16, school: '清华' },
          { name: '小花', age: 14, school: '交大' },
          { name: '小黑', age: 19, school: '西大' },
        ]
      },
      computed:{
        oddstudents(){
          let result = this.students.filter((item,i)=>{
            return item.age %2==0
          })
          return result;
        }
      }
    })
  </script>
</body>

</html>